package br.com.bancodados.ui;


import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.ProgressBar;

public class Splash extends Activity {

	private static final int DEFAULT_DELAY_TIME = 3000; //3 secounds
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        new PrincipalPostExecute().execute();
    }
    
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {		
		return true;
	}
    
  
	private class PrincipalPostExecute extends AsyncTask<Object, Object, Object> {
		ProgressDialog progress = new ProgressDialog(Splash.this);
		
		@Override
		protected void onPreExecute() {
			progress.setMessage("Carregando dados...");
			progress.setTitle("Aguarde...");
			progress.show();
			super.onPreExecute();
		}

		@Override
		protected Object doInBackground(Object... params) {
			try {
				Thread.sleep(DEFAULT_DELAY_TIME);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			return null;
		}

		@Override
		protected void onPostExecute(Object result) {
			if (progress != null) {
				progress.dismiss();
			}
			Intent intent = new Intent("LIST_CARRO");
			startActivity(intent);
			finish();
			super.onPostExecute(result);

		}

	}
}